// 在 Cloud code 里初始化 Express 框架
var express = require('express');
var bodyParser = require('body-parser');
var AV = require('leanengine');
var debug = require('debug')('app');

var app = express();

app.set('views', 'server/views');   // 设置模板目录
app.set('view engine', 'ejs');    // 设置 template 引擎
app.enable('trust proxy');
app.use(express.static('public'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: false}));


app.use('/restful', require('./restful'));



app.use(function (err, req, res, next) {
  debug(err);
});

module.exports = app;
